package com.ntv.presentation.spring.web.event;

import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;

import com.ntv.domain.IEvent;
import com.ntv.service.event.IEventAppService;

/**
 * @author Vedamoorthi Vairam
 *
 */
@Controller
@RequestMapping("/eventhome.html")
public class EventHomeController {
	
	@Autowired
	private IEventAppService eventAppService;
	
	/**
	 * @param eventAppService the eventAppService to set
	 */
	public void setEventAppService(IEventAppService eventAppService) {
		this.eventAppService = eventAppService;
	}

	@RequestMapping(method = RequestMethod.GET)
	public ModelAndView form(Model modelll) throws Exception 
	{
		List<IEvent> events = eventAppService.findEventsByEventDate(new Date());
		Map model = new HashMap();
		model.put("event", events);
		ModelAndView mav = new ModelAndView("home.event", model );
		return mav;
	}
}